home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / CUG187.LZH / READABS.C < prev    next >
C/C++ Source or Header  |  1985-12-31  |  3KB  |  75 lines

  1. /*@******************************************************************/
  2. /*@                                                                 */
  3. /*@ readabs - reads numsecs sectors from the given                  */
  4. /*@        drive starting at logical sector logsec                  */
  5. /*@        into buffer buff.  It uses DOS interrupt                 */
  6. /*@        25h bypassing the normal DOS I/O controls.               */
  7. /*@                                                                 */
  8. /*@   Usage:  readabs(drive, numsecs, logsec, buff);                */
  9. /*@       where drive is the NUMBER of the required                 */
  10. /*@                 drive (e.g. C is 0x03).                         */
  11. /*@             numsecs is the number of sectors to                 */
  12. /*@                 be read.                                        */
  13. /*@             logsec is the starting logical sector.              */
  14. /*@             buff is a pointer to a buffer into                  */
  15. /*@                  which readabs will read.                       */
  16. /*@                                                                 */
  17. /*@ It returns 0 if successful, a 16 bit value otherwise:           */
  18. /*@        Lower Byte              Upper Byte                       */
  19. /*@        0  Write Protect        80h Attachment Failed to Respond */
  20. /*@        1  Unknown Unit         40h Seek Operation Failed        */
  21. /*@        2  Not Ready            08h Bad CRC on Diskette Read     */
  22. /*@        3  Unknown Command      04h Requested Sector Not Found   */
  23. /*@        4  Data Error (CRC)     03h Write Protect Error          */
  24. /*@        5  Bad Request Length   02h Error other than types listed*/     
  25. /*@        6  Seek Error                                            */
  26. /*@        7  Unknown Media Type                                    */
  27. /*@        8  Sector not Found                                      */
  28. /*@        9  <printer only>                                        */
  29. /*@       10  Write Fault                                           */ 
  30. /*@       11  Read Fault                                            */ 
  31. /*@       12  General Failure                                       */
  32. /*@                                                                 */
  33. /*@******************************************************************/
  34.  
  35. int ldrive, lnsecs, llogsec;  /* static variables to make assembler */
  36. char *lbuff;                  /* code simpler */
  37.  
  38.  
  39. int readabs(drive, numsecs, logsec, buff)
  40. int drive, numsecs, logsec;
  41. char *buff;
  42.  
  43.  
  44. {
  45.     ldrive  = drive;         /* copy to easily accessed place */
  46.     lnsecs  = numsecs;
  47.     llogsec = logsec;
  48.     lbuff   = buff;
  49.  
  50. #asm
  51.         PUSH    BX
  52.         PUSH    CX
  53.         PUSH    DX
  54.         PUSH    DI
  55.         PUSH    SI
  56.         PUSH    BP
  57.         MOV     AX,word ldrive_
  58.         MOV     CX,word lnsecs_
  59.         MOV     DX,word llogsec_
  60.         MOV     BX,word lbuff_
  61.         INT     25H
  62.         JC      RDASM1
  63.         MOV     AX,0
  64. RDASM1: NOP
  65.         POPF
  66.         POP     BP
  67.         POP     SI
  68.         POP     DI
  69.         POP     DX
  70.         POP     CX
  71.         POP     BX
  72. #endasm
  73.         return;
  74. }
  75.